//
//  RootTabBarViewController.m
//  daotianjinfu
//
//  Created by 吕涛 on 16/6/14.
//  Copyright © 2016年 吕涛. All rights reserved.
//

#import "RootTabBarViewController.h"
@interface RootTabBarViewController ()
{
    NSInteger _flag;
    UIButton * _RightBtn;
    UIImageView * _menuV;
}

@property (nonatomic,copy) void (^block)(UIButton * btn);

@end

@implementation RootTabBarViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.tabBar.translucent = YES;
    [self addViewSubController];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(setTitleStr) name:@"changeLanguage" object:nil];
    
    
}
- (void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    
}
-(void)addViewSubController{
    
    NSArray * controllerArr = @[@"HomepageViewController",@"TaskViewController",@"ShoppingMallViewController",@"PersonalViewController"];
    NSArray * imageArr = @[@"nav_index_gray",@"nav_search_gray",@"nav_rss_gray",@"nav_chat_gray"];
    NSArray * selectImageArr = @[@"nav_index_blue",@"nav_search_blue",@"nav_rss_blue",@"nav_chat_blue",];
    NSArray * titleArr = @[@"主页",@"任务",@"商城",@"我的"];
    //    NSArray * headImageArr = @[@"head_icon_fwd",@"head_icon_qd",@"head_icon_sr",@"head_icon_user",@"ssss"];
    
    NSMutableArray * nvArr = [[NSMutableArray alloc]init];
    
    [controllerArr enumerateObjectsUsingBlock:^(id  _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
        Class cl = NSClassFromString(obj);
        UIViewController * viewController = [[cl alloc]init];
        UINavigationController * navigation = [[UINavigationController alloc]initWithRootViewController:viewController];
        
        navigation.navigationBar.alpha = 1;
        
        UIImage * image = [[UIImage imageNamed:imageArr[idx]] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
        UIImage * selectImage = [[UIImage imageNamed:selectImageArr[idx]] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
        
        navigation.tabBarItem = [[UITabBarItem alloc]initWithTitle:titleArr[idx] image:image selectedImage:selectImage];
        
        [navigation.tabBarItem setTitlePositionAdjustment:UIOffsetMake(0, -5)];
        
        [nvArr addObject:navigation];
        
    }];
    
    self.viewControllers = nvArr;
}
@end
